#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <unordered_map>
#include <map>

namespace NahidaProject {
	class __declspec(dllexport) XMLWriterNode{
	public:
		std::string Key;
		std::string Value;
		int Depth = 0;

		std::map<std::string, XMLWriterNode> Nodes;
		std::unordered_map<std::string, std::string> Attributes;

		void RemoveIllegalChars(std::string& m_String);
		XMLWriterNode& operator=(const char* m_Value);
		XMLWriterNode& operator[](const char* m_Key);
		XMLWriterNode& operator()(const char* m_AttributeKey, const char* m_AttributeValue);
		std::string GetKey();
		std::string GetOpenTag();
		std::string GetCloseTag();
	};

	class __declspec(dllexport) XMLWriter{
	public:
		XMLWriterNode m_Node;
		XMLWriterNode& operator[](const char* m_Key) { return m_Node[m_Key]; }

		bool m_InsertHeader = true;
		std::string m_Version = "1.0";
		std::string m_Encoding = "UTF-8";
		std::string GetHeader() { return "<?xml version=\"" + m_Version + "\" encoding=\"" + m_Encoding + "\"?>\n"; }

		void BuildString(std::string& m_String, XMLWriterNode& m_Node);
		operator std::string();
		std::string ToString();
		bool OutputFile(const char* m_Path);
	};
}
